﻿@{
    Layout = "~/Views/Shared/_LayoutMobile.cshtml";
    ViewBag.Title = "用户注册";
}

@section Header{
<script>
    Zepto(function ($) {
        $('#btn-register').click(function () {
            if (!$('#txtUserMobile').val()) {
                $('#txtUserMobile').focus();
                utils.ui.showPopMsg('请录入手机号');
                return false;
            }
            if (!$('#txtUserPassword').val()) {
                $('#txtUserPassword').focus();
                utils.ui.showPopMsg('请录入密码');
                return false;
            }
            if (!$('#txtUserCompany').val()) {
                $('#txtUserCompany').focus();
                utils.ui.showPopMsg('请录入公司名称');
                return false;
            }
            if (!$('#txtPhoneCode').val()) {
                $('#txtPhoneCode').focus();
                utils.ui.showPopMsg('请录入手机验证码');
                return false;
            }
            if (!$('#chk-agree').prop('checked')) {
                utils.ui.showPopMsg('请先同意《用户协议》');
                return false;
            }
            return true;
        });
        $('.pwd-toggle').click(function () {
            var $prev = $(this).prev();
            if ($(this).hasClass('active')) {
                $(this).removeClass('active');
                $prev.attr('type', 'password');
            } else {
                $(this).addClass('active');
                $prev.attr('type', 'text');
            }
        });
        $('#btn-phone-code').click(function () {
            if (!$('#txtUserMobile').val()) {
                $('#txtUserMobile').focus();
                utils.ui.showPopMsg('请录入手机号');
                return false;
            }

            var $self = $(this), seconds = 60;

            $.post('@Url.Action("MobileCode")', { txtImageCode: $('#txtImageCode').val(), txtUserMobile: $('#txtUserMobile').val() }, function (data) {
                $('#img-vcode').trigger('click');
                if (data && data.success) {
                    repeat();
                } else {
                    utils.ui.showPopMsg(data ? data.message : '未知错误');
                }
            }, 'json');

            return;

            function repeat() {
                var inter = setInterval(function () {
                    if ((--seconds) <= 0) {
                        clearInterval(inter);
                        $self.text('发送验证码');
                        $self.prop('disabled', false);
                        return;
                    }
                    $self.prop('disabled', true);
                    $self.text(seconds + '秒后重发');
                }, 1000);
            }
        });
        $('#img-vcode').click(function () {
            $(this).attr('src', '@Url.Action("vvcodeImg","Auth")?date=' + new Date());
        });
        $('.text-clear').click(function () {
            $(this).prev().val('');
        });
        var msg = '@ViewBag.Msg';
        if (msg) {
            utils.ui.showPopMsg(msg);
        }
    });
</script>
}
    <form action="?action=submit&redirect=@HttpUtility.UrlEncode(Request["redirect"])&state=@Request["state"]" method="post">
        <div class="m-login">
        	<div class="typeName">注册新账号</div>
        	<ul>
            	<li>
                	<input type="text" maxlength="16" id="txtUserMobile" name="txtUserMobile" placeholder="输入手机号" value="@ViewBag.txtUserMobile"/>
                    <a href="javascript:;" class="text-clear" tabindex="-1"></a>
                </li>
                <li>
                	<input type="password" maxlength="16" id="txtUserPassword" name="txtUserPassword"  placeholder="设置密码" value="@ViewBag.txtUserPassword" />
                    <a href="javascript:;" class="pwd-toggle"></a>
                </li>
                <li>
                	<input type="text" maxlength="100" id="txtUserCompany" name="txtUserCompany" placeholder="输入公司名称"  value="@ViewBag.txtUserCompany"/>
                    <a href="javascript:;" class="text-clear" tabindex="-1"></a>
                </li>
                <li>
                	<select id="selCompanyNature" name="selCompanyNature">
                        <option value="生产企业" selected="selected">@Html._T("生产企业")</option>
                        <option value="经销(代理)商">@Html._T("经销(代理)商")</option>
                        <option value="工程服务">@Html._T("工程服务")</option>
                        <option value="分包商">@Html._T("分包商")</option>
                        <option value="开发商">@Html._T("开发商")</option>
                        <option value="设计院">@Html._T("设计院")</option>
                        <option value="建筑公司">@Html._T("建筑公司")</option>
                        <option value="安装公司">@Html._T("安装公司")</option>
                    </select>
                </li>
                <li>
                	<input type="text" maxlength="6" id="txtPhoneCode" name="txtPhoneCode" placeholder="输入手机验证码" />
                    <button type="button" id="btn-phone-code">获取验证码</button>
                </li>
            </ul>
            <div class="submit-btns">
            	<button type="submit" id="btn-register" class="btn-danger"> 注册</button>
                <div class="other-link f-cb">
                    <p class="f-fl"><input type="checkbox" id="chk-agree" checked="checked"/><label for="chk-agree">同意</label><a class="f-c-red" href="#">《用户协议》</a></p>

                    <p class="f-fr">已有账号,<a class="f-c-red" href="@Url.Action("buildnet","auth")?redirect=@HttpUtility.UrlEncode(Request["redirect"])&state=@Request["state"]">立即登录</a></p>
                </div>
            </div>
        </div>
    </form>